/*
* Copyright 2011 Joshua Carbonneau
*
* This file is part of Texture Chaos.
*
* Texture Chaos is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Texture Chaos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Texture Chaos.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef TILEMAP_H
#define TILEMAP_H

/******************************************************
* Structure to deal with tiles in the texture image.  *
* Keeps track of the number of tiles in the image, as *
* well as which tiles are ok to swap.                 *
* NOTE: This struct is implemented in an ineffiecent  *
* way! May be slow to choose a random tile if the     *
* majority of tiles are set as invalid.               *
*******************************************************/
struct TileMap
{
    int** grid;

    int tileHeight;
    int tileWidth;

    int numTilesY;
    int numTilesX;
};

/******************************************************
* Create a new TileMap from the given config file     *
* filename: The config file to use in the new TileMap *
* returns: A pointer to the new TileMap               *
*******************************************************/
struct TileMap* newTileMap(char* filename);

/********************************
* Deallocate a TileMap          *
* tm: The TileMap to deallocate *
*********************************/
void destroyTileMap(struct TileMap* tm);

/******************************************************************************
* Get a random tile index (in pixel coordinates) from a TileMap               *
* tm: The TileMap to use                                                      *
* tly: The y coordinate of the top right corner of the randomly chosen tile   *
* tlx: The x coordinate of the top right corner of the randomly chosen tile   *
* bry: The y coordinate of the bottom left corner of the randomly chosen tile *
* brx: The x coordinate of the bottom left corner of the randomly chosen tile *
*******************************************************************************/
void getRandomTileCoord(struct TileMap* tm, int* tly, int* tlx, int* bry, int* brx);

#endif
